import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:remixicon/remixicon.dart';
import 'package:super_person_app/constants/colors.dart';
import 'package:super_person_app/pages/find/find_view.dart';
import 'package:super_person_app/pages/home/home_view.dart';
import 'package:super_person_app/pages/message/message_view.dart';
import 'package:super_person_app/pages/my/my_view.dart';

import 'frame_logic.dart';

class FramePage extends StatelessWidget {
  const FramePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final logic = Get.find<FrameLogic>();
    final state = Get.find<FrameLogic>().state;

    return Scaffold(
      body: PageView(
        physics: const NeverScrollableScrollPhysics(),
        controller: state.pageController.value,
        children: const [
          HomePage(),
          MessagePage(),
          FindPage(),
          MyPage(),
        ],
      ),
      bottomNavigationBar: Obx(() => BottomNavigationBar(
        selectedFontSize: 11.sp,
        unselectedFontSize: 11.sp,
        elevation: 0,
        iconSize: 20.sp,
        currentIndex: state.currentIndex.value,
        selectedItemColor: BasicColor.mainColor,
        unselectedItemColor: const Color(0xff6B6B6C),
        showUnselectedLabels: true,
        backgroundColor: const Color(0xffFAFAFA),
        type: BottomNavigationBarType.fixed,
        onTap: logic.setPageIndex,
        items: const [
          BottomNavigationBarItem(icon: Icon(Remix.home_smile_line), activeIcon: Icon(Remix.home_smile_fill), label: "绿洲"),
          BottomNavigationBarItem(icon: Icon(Remix.chat_smile_line), activeIcon: Icon(Remix.chat_smile_fill), label: "消息"),
          BottomNavigationBarItem(icon: Icon(Remix.compass_3_line), activeIcon: Icon(Remix.compass_3_fill), label: "发现"),
          BottomNavigationBarItem(icon: Icon(Remix.user_smile_line), activeIcon: Icon(Remix.user_smile_fill), label: "我的"),
        ],
      )),
    );
  }
}
